﻿using Microsoft.Xna.Framework;

namespace SceneManager.Components
{
	public class OccupiesSpaceComponent : Component
	{
		#region Variables

		private Vector2 _position;
		private float _rotation;
		private float _scale;
		private bool _isMoveable;

		#endregion

		#region Constructors

		public OccupiesSpaceComponent(ComponentCollection parent)
			: base(parent)
		{
			_isMoveable = true;
			_position = Vector2.Zero;
			_rotation = 0.0f;
			_scale = 1.0f;
		}

		#endregion

		#region Properties

		public Vector2 Position
		{
			get
			{
				return _position;
			}
			private set
			{
				if (_position != value)
				{
					_position = value;
					PropertyHasChanged("Position");
				}
			}
		}

		public float Rotation
		{
			get
			{
				return _rotation;
			}
			set
			{
				if (_rotation != value)
				{
					_rotation = value;
					PropertyHasChanged("Rotation");
				}
			}
		}

		public float Scale
		{
			get
			{
				return _scale;
			}
			set
			{
				if (_scale != value)
				{
					_scale = value;
					PropertyHasChanged("Scale");
				}
			}
		}

		public bool IsMoveable
		{
			get
			{
				return _isMoveable;
			}
			set
			{
				if (_isMoveable != value)
				{
					_isMoveable = value;
					PropertyHasChanged("IsMoveable");
				}
			}
		}

		#endregion

		#region Methods

		public void MoveTo(Vector2 position)
		{
			Position = position;
		}

		public void MoveBy(Vector2 amount)
		{
			if (IsMoveable)
			{
				MoveTo(Position + amount);
			}
		}

		#endregion
	}
}